package com.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pojo.entity.SysPermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SysPermissionMapper extends BaseMapper<SysPermission> {
    @Select("<script>" +
            "SELECT DISTINCT sys_permission.* " +
            "FROM sys_permission,sys_role,sys_role_permission " +
            "WHERE sys_role.id = sys_role_permission.role_id " +
            "AND sys_permission.id = sys_role_permission.permission_id " +
            "AND sys_role.id IN " +
            "<foreach item='item' " +
            "   collection='ids' open='(' separator=',' close=')'>#{item}" +
            "</foreach>" +
            "</script>")
    List<SysPermission> selectByRoleIdList(@Param("ids") List<Long> ids);
}
